#encoding:utf8 
import uuid, time
from framework.db import IncDB

class accountData():

	@staticmethod
	def new(name , pwd , ip):
		uid  = str(uuid.uuid1()).replace("-" , "")
		data = dict(
			time = time.time(),
			registerip   = ip,
			lastloginip = "",
			name = name ,
			pwd  = pwd,
			phone= "",
			uid = uid
		)
		return data

	@staticmethod
	def find_by_name(name):
		ret = None
		ret = IncDB.findOnce("accountdata" , {"name":name})
		return ret


	@staticmethod 
	def find_by_namepwd(name , pwd):
		ret = None
		ret = IncDB.findOnce("accountdata" , {"name":name ,"pwd":pwd})
		return ret 

	@staticmethod 
	def insert_account(account):
		account["_id"] = account["uid"]
		ret = IncDB.insertOnce("accountdata" , account)
		return ret
		